#include "s3c2440.h"
#include "uart.h"
#include "nandflash.h"
//#include "supervivi_mini2440.h"

//#define CONGP_OUT(port,port_num) port = (



int main(void)
{
    unsigned int temp;
    unsigned int i,j,k,flag;
    unsigned char  *buf;
    unsigned char ch[512];

    uart_init();
    //send_hex(0xf3);
    //puts("start\n\r");
    flashinit();



    nf_eraseblk(0);

    comdownload();
    buf = (unsigned char*)0x30100000;
    nf_writepage( 0,buf);
    buf = (unsigned char*)0x30100200;
    nf_writepage( 1,buf);
    buf = (unsigned char*)0x30100400;
    nf_writepage( 2,buf);

    buf = (unsigned char*)0x30100600;
    nf_writepage( 3,buf);


    buf = (unsigned char*)0x30100800;
    nf_writepage( 4,buf);


    for(j = 0;j < 5; j++)
    {
    nf_readpage(j,ch);

    for(i = 0; i <512; i++)
    {

        //k = nf_readcolumn(1,i);
        send_hex(ch[i]);
        putch(' ');
    }
    }
    /*
    puts("\n\r");

    nf_readpage(1,ch);
    for(i = 0; i <512; i++)
    {

        //k = nf_readcolumn(1,i);
        send_hex(ch[i]);
        putch(' ');
    }

    puts("\n\r");

    nf_copyback(0,1);

    //nf_writepage(0,vivi);


    nf_readpage(0x0,ch);
    for(i = 0; i <512; i++)
    {

        //k = nf_readcolumn(1,i);
        send_hex(ch[i]);
        putch(' ');
    }

    puts("\n\r");
    nf_readpage(0x1,ch);
    for(i = 0; i <512; i++)
    {

        //k = nf_readcolumn(1,i);
        send_hex(ch[i]);
        putch(' ');
    }

    puts("\n\r");

    //nf_eraseblk(0);


    */
    while(1)
    {



    /*uart_init();
    for(i = 0x31000000; i < 0x31000000 + 16; i++)
    {
    ch = *(volatile unsigned char *)i;
    send_hex(ch);
    putch(' ');
    }*/
    }
    return 1;

}

